using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class EmailRecive
    {
        public string Email { get; set; }
        public bool IsDeleted { get; set; }
        public DateTime CreatedDate { get; set; }
        public DateTime DeletedDate { get; set; }

        #region EmailReciveSelectAll
        public static List<EmailRecive> EmailReciveSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.EmailRecive.EmailReciveSelectAll(strSearch,top,bottom,ConnectionString);
            List<EmailRecive> EmailReciveList = new List<EmailRecive>();
            while(dr.Read())
            {
                EmailRecive myEmailRecive = new EmailRecive
                {
                    Email = !dr.IsDBNull(dr.GetOrdinal("Email")) ? (string)dr["Email"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    DeletedDate = !dr.IsDBNull(dr.GetOrdinal("DeletedDate")) ? (DateTime)dr["DeletedDate"] : DateTime.Now
                };
                EmailReciveList.Add(myEmailRecive);
        }
        dr.Close();
        dr.Dispose();
        return EmailReciveList;
        }
        #endregion
        #region EmailReciveSelectRow
        public static EmailRecive EmailReciveSelectRow(string Email, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.EmailRecive.EmailReciveSelectRow(Email, ConnectionString);
            EmailRecive emailrecive = null;

            if(dr.Read())
            {
                emailrecive= new EmailRecive
                {
                    Email = !dr.IsDBNull(dr.GetOrdinal("Email")) ? (string)dr["Email"] : null,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,
                    CreatedDate = !dr.IsDBNull(dr.GetOrdinal("CreatedDate")) ? (DateTime)dr["CreatedDate"] : DateTime.Now,
                    DeletedDate = !dr.IsDBNull(dr.GetOrdinal("DeletedDate")) ? (DateTime)dr["DeletedDate"] : DateTime.Now,

                };
            }
        dr.Close();
        dr.Dispose();
        return emailrecive;
        }
        #endregion
        #region EmailReciveInsertRow
        public static void EmailReciveInsertRow(string Email, bool IsDeleted, DateTime CreatedDate, DateTime DeletedDate, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.EmailRecive.EmailReciveInsertRow(Email, IsDeleted, CreatedDate, DeletedDate, ConnectionString);
        }
        #endregion
        #region EmailReciveUpdateRow
        public static void EmailReciveUpdateRow(string Email, bool IsDeleted, DateTime CreatedDate, DateTime DeletedDate, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.EmailRecive.EmailReciveUpdateRow(Email, IsDeleted, CreatedDate, DeletedDate, ConnectionString);
        }
        #endregion
        #region EmailReciveDeleteRow
        public static void EmailReciveDeleteRow(string Email, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.EmailRecive.EmailReciveDeleteRow(Email,ConnectionString);
        }
        #endregion
    }
}
